home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
PROGRAMM
/
CC_C
/
0574.ZIP
/
OPEN.ASM
< prev
next >
Wrap
Assembly Source File
|
1986-08-30
|
841b
|
49 lines
include compiler.inc
ttl OPEN, 1.04, 08-30-86, clr
;low-level handle opener (was _opn() in prev versions)
dseg
exterr
cseg
procdef open, <<path, ptr>, <mode, byte>>
pushds
xor ax,ax
moverr ax
ldptr dx,path,ds ;name pointer
mov al,mode ;mode value
inc al ;to simplify testing
and al,3 ;take it mod 3
jz err ; 0 not valid
test al,1 ;read or append?
jz cre ;no, must be write only
dec al ;to DOS mode code
mov ah,3dh ;let DOS open it
int 21h
jnb ex2 ;opened OK
cmp ax,2 ;file not found?
jnz err ;no, real error
mov bl,mode ;yes, check for W
test bl,2
jz err ;nope, real error
cre:
xor cx,cx ;no attributes
mov ax,3C00h ;on new file
int 21h
jnb ex2 ;created OK
err:
moverr ax ;error
mov ax,-1
ex2:
pret
pend open
finish